package com.haoting.mamba.news.controller;

import java.util.Arrays;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.haoting.mamba.news.entity.SupportEntity;
import com.haoting.mamba.news.service.SupportService;
import com.haoting.common.utils.PageUtils;
import com.haoting.common.utils.R;



/**
 * 
 *
 * @author tanghao
 * @email 767417609@qq.com
 * @date 2021-03-14 19:47:10
 */
@RestController
@RequestMapping("news/support")
public class SupportController {
    @Autowired
    private SupportService supportService;

    /**
     * 列表
     */
    @RequestMapping("/list")
//    @RequiresPermissions("news:support:list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = supportService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{newsId}")
//    @RequiresPermissions("news:support:info")
    public R info(@PathVariable("newsId") String newsId){
		SupportEntity support = supportService.getById(newsId);

        return R.ok().put("support", support);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
//    @RequiresPermissions("news:support:save")
    public R save(@RequestBody SupportEntity support){
		supportService.save(support);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
//    @RequiresPermissions("news:support:update")
    public R update(@RequestBody SupportEntity support){
		supportService.updateById(support);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
//    @RequiresPermissions("news:support:delete")
    public R delete(@RequestBody String[] newsIds){
		supportService.removeByIds(Arrays.asList(newsIds));

        return R.ok();
    }

}
